//
//  HBHMainInformationCell.m
//  HubeiHotel
//
//  Created by 张露杰 on 17/11/14.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "HBHMainInformationCell.h"
#import "SDCycleScrollView.h"
@interface HBHMainInformationCell()<SDCycleScrollViewDelegate>
@property (nonatomic,strong)SDCycleScrollView *cycleScrollView;//轮播
@property (nonatomic,strong)NSMutableArray *titieArr;//标题Arr
@end
@implementation HBHMainInformationCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    //    继承父类
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
    }
    return self;
}

-(void)loadCellWithData:(NSMutableArray *)data
{
    //    重新布局
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, .5)];
    lineView.backgroundColor = backColor;
    [self.contentView addSubview:lineView];
    
    UIImageView *imageV = [TomamaUI createImageView:CGRectMake(0, 0, 33*screenW_6, 33*screenW_6) backGroundImageV:@"Main_news"];
    [self.contentView addSubview:imageV];
    imageV.center = CGPointMake(33*screenW_6, 30*screenW_6);
    
    UIView *lineUpRightView = [[UIView alloc]initWithFrame:CGRectMake(66*screenW_6, 0, .5, 33*screenW_6)];
    lineUpRightView.backgroundColor = backColor;
    lineUpRightView.center = CGPointMake(lineUpRightView.center.x, imageV.center.y);
    [self.contentView addSubview:lineUpRightView];
    
    [self.contentView addSubview:self.cycleScrollView];
    self.cycleScrollView.titlesGroup = data;
    self.cycleScrollView.imageURLStringsGroup = data;
//    for (int i = 0; i<[data count]; i++) {
//        UILabel *titleLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lineUpRightView.frame) + 14*screenW_6, 14*screenW_6, SCREENW - CGRectGetMaxX(lineUpRightView.frame) - 34*screenW_6, 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:TextBlack text:@"你猜我猜不猜你猜我猜不猜猜你猜我猜不猜"];
//        [self.contentView addSubview:titleLabel];
//
//    }
//
//    UILabel *subLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lineUpRightView.frame) + 14*screenW_6, CGRectGetMaxY(titleLabel.frame) + 8*screenW_6, SCREENW - CGRectGetMaxX(lineUpRightView.frame) - 34*screenW_6, 13*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:13*screenW_6] textColor:TextBlack text:@"我猜不猜你猜我猜不猜猜你猜我猜不猜"];
//    [self.contentView addSubview:subLabel];
    
}
-(SDCycleScrollView *)cycleScrollView//轮播
{
    if (!_cycleScrollView) {
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(80*screenW_6,10*screenW_6,SCREENW-100*screenW_6,40*screenW_6) delegate:self placeholderImage:[UIImage imageNamed:@""]];
        _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
//        _cycleScrollView.currentPageDotColor = [UIColor whiteColor];
        _cycleScrollView.autoScrollTimeInterval = 4.0f;
        _cycleScrollView.userInteractionEnabled = YES;
        _cycleScrollView.delegate = self;
        _cycleScrollView.scrollDirection = NO;
        _cycleScrollView.onlyDisplayText = YES;
        _cycleScrollView.titleLabelTextFont = [UIFont systemFontOfSize:14];
        _cycleScrollView.titleLabelHeight = 40*screenW_6;
        _cycleScrollView.titleLabelBackgroundColor = [UIColor whiteColor];
        _cycleScrollView.titleLabelTextColor = TextBlack;
        _cycleScrollView.backgroundColor = [UIColor whiteColor];
    }
    return _cycleScrollView;    
}
//轮播图片点击事件
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index;
{
    if (_block) {
        _block(index);
    }
}
@end
